<%--
  Created by IntelliJ IDEA.
  User: 李元峰
  Date: 2022/9/20
  Time: 16:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<div class="pxp-preloader"><span>Loading...</span></div>
<script src="/static/web/js/jquery-3.4.1.min.js"></script>

<div class="pxp-dashboard-side-panel d-none d-lg-block">
    <div class="pxp-logo">
        <a href="index.html" class="pxp-animate"><span style="color: var(--pxpMainColor)">个人</span>用户</a>
    </div>

    <nav class="mt-3 mt-lg-4 d-flex justify-content-between flex-column pb-100">
        <div class="pxp-dashboard-side-label">管理工具</div>
        <ul class="list-unstyled">
            <li id="personalHomePage"><a href="/web/personal/homepage/personalHomePage"><span class="fa fa-home"></span>个人中心首页</a></li>
            <li id="curriculumVitae"><a href="/web/personal/curriculumVitae"><span class="fa fa-pencil"></span>编写个人简历</a></li>
            <li id="personalApplicationJobs"><a href="/web/personal/homepage/personalApplicationsJobs"><span class="fa fa-file-text-o"></span>申请工作状态</a></li>
            <li id="personalCollectJobs"><a href="/web/personal/homepage/personalCollectJobs"><span class="fa fa-heart-o"></span>收藏工作</a></li>
            <li id="personalCenter"><a href="/web/personal/personalCenter"><span class="fa fa-lock"></span>更改密码</a></li>
        </ul>
        <div class="pxp-dashboard-side-label mt-3 mt-lg-4">通知</div>
        <ul class="list-unstyled">
            <li id="messagea">
                <a href="/web/companies/userMessage" class="d-flex justify-content-between align-items-center">
                    <div><span class="fa fa-envelope-o"></span>收件箱</div>
                    <span class="badge rounded-pill">14</span>
                </a>
            </li>
            <li id="userNotice">
                <a href="/web/personal/userNotice" class="d-flex justify-content-between align-items-center">
                    <div><span class="fa fa-bell-o"></span>通知</div>
                    <span class="badge rounded-pill" id="leftNotice">${requestScope.numOfNotice}</span>
                </a>
            </li>
        </ul>
    </nav>

    <nav class="pxp-dashboard-side-user-nav-container pxp-is-candidate">
        <div class="pxp-dashboard-side-user-nav">
            <div class="dropdown pxp-dashboard-side-user-nav-dropdown dropup">
                <a role="button" class="dropdown-toggle" data-bs-toggle="dropdown">
                    <div class="pxp-dashboard-side-user-nav-avatar pxp-cover" style="background-image: url(/static/uploadImages/${sessionScope.user.face});"></div>
                    <div class="pxp-dashboard-side-user-nav-name">${sessionScope.user.name}</div>
                </a>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="/web/personal/index">个人首页</a></li>
                    <li><a class="dropdown-item" href="/web/personal/curriculumVitae">编辑个人简历</a></li>
                    <li><a class="dropdown-item" href="/web/personal/signIn">退出登录</a></li>
                </ul>
            </div>
        </div>
    </nav>
</div>

<div class="pxp-dashboard-content">
    <div class="pxp-dashboard-content-header pxp-is-candidate">
        <div class="pxp-nav-trigger navbar pxp-is-dashboard d-lg-none">
            <a role="button" data-bs-toggle="offcanvas" data-bs-target="#pxpMobileNav" aria-controls="pxpMobileNav">
                <div class="pxp-line-1"></div>
                <div class="pxp-line-2"></div>
                <div class="pxp-line-3"></div>
            </a>
            <div class="offcanvas offcanvas-start pxp-nav-mobile-container pxp-is-dashboard pxp-is-candidate" tabindex="-1" id="pxpMobileNav">
                <div class="offcanvas-header">
                    <div class="pxp-logo">
                        <a href="/web/personal/index" class="pxp-animate"><span style="color: var(--pxpMainColor)">个人</span>用户</a>
                    </div>
                    <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
                </div>
                <div class="offcanvas-body">
                    <nav class="pxp-nav-mobile">
                        <ul class="navbar-nav justify-content-end flex-grow-1">
                            <li class="pxp-dropdown-header">管理工具</li>
                            <li class="nav-item"><a href="/web/personal/homepage/personalHomePage"><span class="fa fa-home"></span>个人中心主页</a></li>
                            <li class="nav-item"><a href="/web/personal/curriculumVitae"><span class="fa fa-pencil"></span>编写个人简历</a></li>
                            <li class="nav-item"><a href="/web/personal/homepage/personalApplicationsJobs"><span class="fa fa-file-text-o"></span>申请工作状态</a></li>
                            <li class="nav-item"><a href="/web/personal/homepage/personalCollectJobs"><span class="fa fa-heart-o"></span>收藏工作</a></li>
                            <li class="nav-item"><a href="/web/personal/personalCenter"><span class="fa fa-lock"></span>更改密码</a></li>
                            <li class="nav-item">
                                <a href="candidate-dashboard-inbox.html" class="d-flex justify-content-between align-items-center">
                                    <div><span class="fa fa-envelope-o"></span>消息</div>
                                    <span class="badge rounded-pill">14</span>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="/web/personal/userNotice" class="d-flex justify-content-between align-items-center">
                                    <div><span class="fa fa-bell-o"></span>通知</div>
                                    <span class="badge rounded-pill">5</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
        <nav class="pxp-user-nav pxp-on-light">
            <div class="dropdown pxp-user-nav-dropdown pxp-user-notifications">
                <a role="button" class="dropdown-toggle" data-bs-toggle="dropdown">
                    <span class="fa fa-bell-o"></span>
                    <div class="pxp-user-notifications-counter" id="numOfNotice">${requestScope.numOfNotice}</div>
                </a>
                <ul class="dropdown-menu dropdown-menu-end">
                    <c:forEach items="${requestScope.notices.list}" var="notice">
                        <li><a class="dropdown-item" href="/web/personal/personalCompanyDetail/${notice.company.id}"><strong>${notice.company.name}</strong> ${notice.noticeMode.noticeInfo} <span class="pxp-is-time"></span></a></li>
                        <input type="hidden" class="notice-time" value="<fmt:formatDate value='${notice.noticeTime}' pattern='yyyy-MM-dd HH:mm:ss'/>">
                    </c:forEach>
                    <li><hr class="dropdown-divider"></li>
                    <li><a class="dropdown-item pxp-link" href="/web/personal/userNotice">读取所有</a></li>
                </ul>
            </div>
            <div class="dropdown pxp-user-nav-dropdown">
                <a role="button" class="dropdown-toggle" data-bs-toggle="dropdown">
                    <div class="pxp-user-nav-avatar pxp-cover" id="faceHead" style="background-image: url(/static/uploadImages/${sessionScope.user.face});"></div>
                    <div class="pxp-user-nav-name d-none d-md-block">${sessionScope.user.name}</div>
                </a>
                <ul class="dropdown-menu dropdown-menu-end">
                    <li><a class="dropdown-item" href="/web/personal/index">个人首页</a></li>
                    <li><a class="dropdown-item" href="/web/personal/curriculumVitae">编辑个人简历</a></li>
                    <li><a class="dropdown-item" href="/web/personal/signIn">退出登录</a></li>
                </ul>
            </div>
        </nav>
    </div>

<script>
    $(function (){
       if ($("title").html()=="个人简历")
       {
            $("#curriculumVitae").attr("class","pxp-active");
       }
        if ($("title").html()=="个人中心首页")
        {
            $("#personalHomePage").attr("class","pxp-active");
        }
        if ($("title").html()=="申请职位状态")
        {
            $("#personalApplicationJobs").attr("class","pxp-active");
        }
        if ($("title").html()=="收藏职位")
        {
            $("#personalCollectJobs").attr("class","pxp-active");
        }
        if ($("title").html()=="更改密码")
        {
            $("#personalCenter").attr("class","pxp-active");
        }
        if ($("title").html()=="通知")
        {
            $("#userNotice").attr("class","pxp-active");
        }

        $(".notice-time").each(function (){
            let noticeTime = $(this).val();
            let nowTime = new Date().getTime();
            let oldTime = new Date(noticeTime).getTime();
            let time = nowTime - oldTime;
            let minute = parseInt(time/1000/60%60);
            let hour = parseInt(time/1000/60/60%24);
            let day = parseInt(time/1000/60/60/24%30);
            let info = "";
            if (minute<1&&hour<1&&day<1)
            {
                info = "刚刚";
                $(this).prev().find(".pxp-is-time").html(info);
                return;
            }
            info = "前"
            if (minute>=1) {
                info = minute + "分钟" +info;
            }
            if (hour>=1)
            {
                info = hour+"小时"+info;
            }
            if (day>=1)
            {
                info = day+"天"+info;
            }
            $(this).prev().find(".pxp-is-time").html(info);
        });
    });
</script>
